package br.usp.ime.protoc.neuroimagem;

import java.util.HashSet;
import java.util.Iterator;

import br.usp.ime.protoc.fujaba.FEmptyIterator;

public class ExameRMEstrutural
extends Exame
{
   /**
    * <pre>
    *                    1              has               1..* 
    * ExameRMEstrutural --------------------------------------- Espectroscopia
    *                    exameRMEstrutural      espectroscopia 
    * </pre>
    */
   private HashSet espectroscopia;

   public boolean addToEspectroscopia(Espectroscopia value)
   {
      boolean changed = false;
      if (value != null)
      {
         if (this.espectroscopia == null)
         {
            this.espectroscopia = new HashSet (); // or FTreeSet () or FLinkedList ()
         }
         
         changed = this.espectroscopia.add (value);
         if (changed)
         {
            value.setExameRMEstrutural (this);
         }
         
      }
      return changed;
   }

   public boolean hasInEspectroscopia(Espectroscopia value)
   {
      return ((this.espectroscopia != null) &&
              (value != null) &&
              this.espectroscopia.contains (value));
   }

   public Iterator iteratorOfEspectroscopia()
   {
      return ((this.espectroscopia == null)
              ? FEmptyIterator.get ()
              : this.espectroscopia.iterator ());
   }

   public void removeAllFromEspectroscopia()
   {
      Espectroscopia tmpValue;
      Iterator iter = this.iteratorOfEspectroscopia ();
      while (iter.hasNext ())
      {
         tmpValue = (Espectroscopia) iter.next ();
         this.removeFromEspectroscopia (tmpValue);
      }
   }

   public boolean removeFromEspectroscopia(Espectroscopia value)
   {
      boolean changed = false;
      if ((this.espectroscopia != null) && (value != null))
      {
         
         changed = this.espectroscopia.remove (value);
         if (changed)
         {
            value.setExameRMEstrutural (null);
         }
         
      }
      return changed;
   }

   public int sizeOfEspectroscopia()
   {
      return ((this.espectroscopia == null)
              ? 0
              : this.espectroscopia.size ());
   }

   public void removeYou()
   {
      removeAllFromEspectroscopia ();
      super.removeYou ();
   }

}
